/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.great.functionalCore;

import de.offis.faint.controller.MainController;
import de.offis.faint.detection.plugins.betaface.BetafaceDetection;
import de.offis.faint.model.ImageModel;
import de.offis.faint.model.Region;

/**
 *
 * @author Windson
 */
public class FaceDetection {

    public static Region[] doInBackground(ImageModel model) {
			Region[] result = null;
			try{
//                MainController controller=MainController.getInstance();
  //              controller.
             //  IDetectionPlugin[] a=MainController.getInstance().getDetectionHotSpot().getAvailablePlugins();
              // for(int i=0; i< a.length;i++){
                //System.out.println("i:"+i+"Nome: "+a[i].getDescription());
               //}
                //MainController.getInstance().getDetectionHotSpot().setActivePlugin(new BetafaceDetection());
				String pluginName = FaceDetection.getClassName(
						MainController.getInstance().getDetectionHotSpot().getActivePlugin().getClass());

				System.out.println("Running " + pluginName + " ... ");

				result = MainController.getInstance().detectFaces(model, false);
				int numFaces = 0;
				if (result != null){
					numFaces = result.length;
				}
					System.out.println("done.\nNumber of possible faces found: " + numFaces + "\n");
			}
			catch(Exception t){
				//new ExceptionDialog(mainFrame,t, "Detection failed");
				//done();
                t.printStackTrace();
			}
			return result;
		}
    public static String getClassName(Class theClass){
		return theClass.toString().substring(theClass.toString().lastIndexOf('.')+1);
	}


}
